<extend name="Public:base"/>

<!--侧边导航-->
<block name="aside">
    <include file="Public:aside"/>
</block>

<block name="main">
<div id="yzh-content" class="col-xs-12">

    <form id="myform" class="form-horizontal" action="{:U('User/edit')}" method="post">
        <input type="hidden" name="question" value="{$info.age}">
        <input type="hidden" name="answer" value="{$info.address}">
        <input type="hidden" name="id" value="{$info['id']}" />
        <div class="form-group">
            <label class="col-sm-2 control-label">用户名</label>
            <div class="col-xs-4">
                <input type="text" class="form-control" name="username" value="{$info.username}" >
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">密码</label>
            <div class="col-xs-4">
                <input type="password" id="password" name="password" class="form-control" />
                <em for="password" generated="true" class="info">不修改密码请留空。</em>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">确认密码</label>
            <div class="col-xs-4">
                <input type="password" id="password" name="repassword" class="form-control" />
                <em for="password" generated="true" class="info">不修改密码请留空。</em>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">邮箱</label>
            <div class="col-xs-4">
                <input type="text" class="form-control"  name="email" value="{$info.email}" >
            </div>
        </div>

        <if condition="$Think.session.admin.id eq 1">
        <div class="form-group env-class">
            <label class="col-sm-2 control-label">所属角色</label>
            <div class="col-xs-4">
                <select name="role" class="form-control">
                <volist name="role" id="r">
                    <option {if $info['role']==$r['id']}selected="selected"{/if} value="{$r['id']}">{$r['name']}</option>
                </volist>
                </select>
            </div>
        </div>
        <else/>
            <input type="hidden" name="role" value="2">
        </if>

        <div class="form-group">
            <label class="col-sm-2 control-label">状态</label>
            <div class="col-xs-4">
                <input type="radio" name="status" value="1" <eq name="info['status']" value="1">checked="checked"</eq> />启用
                <input type="radio" name="status" value="0" <eq name="info['status']" value="0">checked="checked"</eq> />禁用
            </div>
        </div>
        <div class="form-actions">
            <input type="submit" name="dosubmit" value="确认" class="btn btn-primary">
            <a class="btn btn-default" href="javascript:window.history.go(-1);">返回</a>
        </div>
    </form>
</div>
</block>

<block name="script">
<script type="text/javascript">
    $(document).ready(function() {
        $('#myform').ajaxForm({
            success:  complete,  // post-submit callback
            dataType: 'json'
        });
    });

    function complete(data){
        if (data.status == 1) {
            layer.msg(data.info, {
                icon: 1,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            }, function(){
                window.location.href = "{$Think.cookie.__forward__}";
                return true;
            });
        } else {
            layer.msg(data.info, {
                icon: 2,
                time: 2000 //2秒关闭（如果不配置，默认是3秒）
            });
        }
    }
</script>
</block>